package leetcode.offer022;

import leetcode.helper.tree.ListNode;

public class Solution extends Offer022 {

	@Override
	public ListNode getKthFromEnd(ListNode head, int k) {
		if ((head == null) || (k < 1))
			return head;
		int r = 0;
		ListNode rln = head;
		while (r < k && rln != null) {
			rln = rln.next;
			r++;
		}
		while (rln != null) {
			rln = rln.next;
			head = head.next;
		}
		return head;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
	}

}
